home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 4 / Apprentice-Release4.iso / Source Code / C++ / Snippets / QD3D Juggler / Juggler Sources / CJugglerApp.cp < prev    next >
Encoding:
Text File  |  1995-12-27  |  4.6 KB  |  172 lines  |  [TEXT/CWIE]

  1. // ===========================================================================
  2. //    <PP Starter Source>.cp         ©1994-1995 Metrowerks Inc. All rights reserved.
  3. // ===========================================================================
  4. //
  5. //    This file contains the starter code for a PowerPlant application
  6.  
  7. #include "CJugglerApp.h"
  8. #include "CQ3BoxesPane.h"
  9. #include "CPropPane.h"
  10. #include "StQD3DInitializer.h"
  11.  
  12. #include "CQD3DErrorsDoc.h"        // for reporting QD3D errors
  13.  
  14. #include <LGrowZone.h>
  15. #include <LWindow.h>
  16. #include <PP_Messages.h>
  17. #include <PP_Resources.h>
  18. #include <PPobClasses.h>
  19. #include <UDrawingState.h>
  20. #include <UMemoryMgr.h>
  21. #include <URegistrar.h>
  22. #include <LEditField.h>
  23.  
  24. // put declarations for resource ids (ResIDTs) here
  25.  
  26. const ResIDT    window_Boxes        = 1;
  27. const ResIDT    window_Prop            = 2;
  28. #define window_Sample    window_Prop    // switch to set the window type
  29. const PaneIDT    PaneID_PropPane        = 200;
  30.  
  31. const CommandT    cmd_NewPropPane = 1200;
  32.  
  33. // ===========================================================================
  34. //        • Main Program
  35. // ===========================================================================
  36.  
  37. void main(void)
  38. {
  39.                                     // Set Debugging options
  40.     SetDebugThrow_(debugAction_Alert);
  41.     SetDebugSignal_(debugAction_Alert);
  42.  
  43.     InitializeHeap(4);                // Initialize Memory Manager
  44.                                     // Parameter is number of Master Pointer
  45.                                     //   blocks to allocate
  46.     
  47.                                     // Initialize standard Toolbox managers
  48.     UQDGlobals::InitializeToolbox(&qd);
  49.     
  50.     new LGrowZone(20000);            // Install a GrowZone function to catch
  51.                                     //    low memory situations.
  52.     
  53.     StQD3DInitializer q3;            // Initalize QuickDraw 3D
  54.     if (q3.GetStatus()==kQ3Success) {
  55.         CJugglerApp    theApp;
  56.         // Make the QD3D Error Message window.
  57.         CQD3DErrorsDoc * doc = new CQD3DErrorsDoc();
  58.         theApp.Run();
  59.     }
  60. }
  61.  
  62.  
  63. // ---------------------------------------------------------------------------
  64. //        • CJugglerApp             // replace this with your App type
  65. // ---------------------------------------------------------------------------
  66. //    Constructor
  67.  
  68. CJugglerApp::CJugglerApp()
  69. {
  70.     // Register functions to create core PowerPlant classes
  71.     
  72.     RegisterAllPPClasses();
  73.     URegistrar::RegisterClass(CQ3BoxesPane::class_ID,    CQ3BoxesPane::CreateQ3BoxesPaneStream);
  74.     URegistrar::RegisterClass(CPropPane::class_ID,    CPropPane::CreatePropPaneStream);
  75.     
  76. }
  77.  
  78.  
  79. // ---------------------------------------------------------------------------
  80. //        • ~CJugglerApp            // replace this with your App type
  81. // ---------------------------------------------------------------------------
  82. //    Destructor
  83. //
  84.  
  85. CJugglerApp::~CJugglerApp()
  86. {
  87. }
  88.  
  89. // ---------------------------------------------------------------------------
  90. //        • StartUp
  91. // ---------------------------------------------------------------------------
  92. //    This function lets you do something when the application starts up. 
  93. //    For example, you could issue your own new command, or respond to a system
  94. //  oDoc (open document) event.
  95.  
  96. void
  97. CJugglerApp::StartUp()
  98. {
  99.     ObeyCommand(cmd_New, nil);        // EXAMPLE, create a new window
  100. }
  101.  
  102. // ---------------------------------------------------------------------------
  103. //        • ObeyCommand
  104. // ---------------------------------------------------------------------------
  105. //    Respond to commands
  106.  
  107. Boolean
  108. CJugglerApp::ObeyCommand(
  109.     CommandT    inCommand,
  110.     void        *ioParam)
  111. {
  112.     Boolean        cmdHandled = true;
  113.     LWindow        *theWindow;
  114.  
  115.     switch (inCommand) {
  116.     
  117.         // Deal with command messages (defined in PP_Messages.h).
  118.         // Any that you don't handle will be passed to LApplication
  119.              
  120.         case cmd_New:
  121.             theWindow = LWindow::CreateWindow(window_Boxes, this);    
  122.             break;
  123.  
  124.         case cmd_NewPropPane:
  125.             theWindow = LWindow::CreateWindow(window_Prop, this);    
  126.             
  127.             CPropPane *pane = (CPropPane*)theWindow->FindPaneByID(PaneID_PropPane);
  128.             if (pane) {
  129.                 theWindow->SetLatentSub(pane);
  130.             }
  131.             break;
  132.             
  133.         default:
  134.             cmdHandled = LApplication::ObeyCommand(inCommand, ioParam);
  135.             break;
  136.     }
  137.     
  138.     return cmdHandled;
  139. }
  140.  
  141. // ---------------------------------------------------------------------------
  142. //        • FindCommandStatus
  143. // ---------------------------------------------------------------------------
  144. //    This function enables menu commands.
  145. //
  146.  
  147. void
  148. CJugglerApp::FindCommandStatus(
  149.     CommandT    inCommand,
  150.     Boolean        &outEnabled,
  151.     Boolean        &outUsesMark,
  152.     Char16        &outMark,
  153.     Str255        outName)
  154. {
  155.  
  156.     switch (inCommand) {
  157.     
  158.         // Return menu item status according to command messages.
  159.         // Any that you don't handle will be passed to LApplication
  160.  
  161.         case cmd_New:            // enable the New command
  162.         case cmd_NewPropPane:
  163.             outEnabled = true;
  164.             break;
  165.  
  166.         default:
  167.             LApplication::FindCommandStatus(inCommand, outEnabled,
  168.                                                 outUsesMark, outMark, outName);
  169.             break;
  170.     }
  171. }
  172.